import Vue from 'vue'

import Cookies from 'js-cookie'

import 'normalize.css/normalize.css' // a modern alternative to CSS resets

import Element from 'element-ui'
import './styles/element-variables.scss'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import i18n from './lang' // internationalization
import './icons' // icon
import './permission' // permission control
import './utils/error-log' // error log

import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'


VXETable.setup({
    zIndex: 49001,
    table: {
        align: "center",//单元格居中
        resizable: false,//表格列宽可拖拽
        autoResize: true,//数据变化表格自动resize
        border: true, //表格边框
        showOverflow: true, //显示超出tips
        showHeaderOverflow: true, //表头超出tips
        showFooterOverflow: true,//表尾超出tips
        highlightHoverRow: true,//单元格hover高亮
        highlightCurrentRow: true,//单元格focus高亮
        tooltipConfig: { enterable: true },//tips 鼠标可进入
        sortConfig: { multiple: true, trigger: 'cell' }, //点击表头单元格触发排序
        
    },
    grid: {
        size: "mini",//表格整体大小  medium, small, mini
        toolbarConfig: {
            slots: {
                buttons: "toolbar_buttons", //默认表头buttons 插槽
            },
        },
    }
})


//icon css
import '@/assets/icon/iconfont.css'


Vue.use(VXETable)

import * as filters from './filters' // global filters
Vue.use(Element, {
    size: Cookies.get('size') || 'medium', // set element-ui default size
    i18n: (key, value) => i18n.t(key, value)
})

// register global utility filters
Object.keys(filters).forEach(key => {
    Vue.filter(key, filters[key])
})

Vue.config.productionTip = false


//Date 原型上挂载format方法
Date.prototype.format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1,                 //月份 
        "d+": this.getDate(),                    //日 
        "h+": this.getHours(),                   //小时 
        "m+": this.getMinutes(),                 //分 
        "s+": this.getSeconds(),                 //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds()             //毫秒 
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    return fmt;
}




new Vue({
    el: '#app',
    router,
    store,
    i18n,
    render: h => h(App)
})
